package sguigu.threee.config;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;
import sguigu.threee.entity.OrderEntity;

import java.io.IOException;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2024-2-23 14:11
 * @Version: 1.0
 */
@Configuration
public class RabbitmqListenerConfig {

    //监听订单过期消息
    @RabbitListener(queues = "order.release.order.queue")
    public void listener(OrderEntity orderEntity, Channel channel, Message message) throws IOException {
        System.out.println("收到过期订单："+orderEntity.getOrderSn());
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
